<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="renderer" content="webkit" />
  <meta name="force-rendering" content="webkit" />
  <title></title>
  <link type="text/css" rel="stylesheet" href="/css/login.css" />
  <script type="text/javascript" src="/js/jquery.js"></script>
  <script type="text/javascript" src="/js/login.js"></script>
</head>

<body>
  <form class="loginBox" id="loginForm" method="post">
    <h1>欢迎登陆</h1>
    <div class="item">
      <div class="icon"><img src="img/icon1.png" /></div>
      <div class="txt"><input name="username" id="username" type="text" placeholder="请输入您的用户名" /></div>
    </div>
    <div class="item">
      <div class="icon"><img src="img/icon2.png" /></div>
      <div class="txt"><input name="password" id="password" type="password" placeholder="请输入您的密码" /></div>
    </div>
    <div class="item_2">
      <label><input name="saved" id="saved" type="checkbox" value="1" />
        <span>记住密码</span></label>
      <a href="/pwd">忘记密码？</a>
    </div>
    <div class="item_3">
      <input name="" disabled type="submit" value="安全登录" class="btn" />
    </div>
    <div class="item_4">
      还没有账号？<a href="/register">立即注册</a>
    </div>
  </form>

</body>
<script>
  $(document).ready(function () {
    $('#loginForm').submit(function (event) {
      event.preventDefault();
      var username = $('#username').val();
      var password = $('#password').val();
      $.ajax({
        url: '/login',
        type: 'POST',
        data: { username: username, password: password, saved: $('#saved').is(':checked') },
        success: function (response) {
          if (response.status === 'success') {
            window.location.href = response.redirect;
          } else {
            alert(response.message);
          }
        },
        error: function (error) {
          console.error('登录失败:', error);
        }
      });
    });
  });
</script>

</html>